import store from "@/store";
import { numberFormat } from "@/util/util.js";
export const tableOptionCash = {
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  menu: false,
  header: false,
  column: [
    {
      type: "input",
      label: "唯一标识",
      prop: "id",
      hide: true
    },
    {
      type: "input",
      label: "主表关联ID",
      prop: "relationId",
      hide: true
    },
    {
      type: "select",
      label: "TVM编号",
      prop: "tvmCode",
      filterable: true,
      cell: true,
      width: 110,
      dicUrl: "/support/swpmtvmcode/page",
      props: {
        label: "tvmCode",
        value: "tvmCode",
        res: "data.records"
      },
      dicQuery: {
        size: -1,
        stationCode: store.getters.userInfo.stationCode,
        status: "1"
      }
    },
    {
      type: "number",
      label: "接收纸币",
      prop: "receiveNotes",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "number",
      label: "接收硬币",
      prop: "receiveCoin",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "number",
      label: "纸币找零",
      prop: "noteChangen",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "number",
      label: "硬币找零",
      prop: "coinChange",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "number",
      label: "故障退款金额",
      prop: "faultRefundAmount",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "number",
      label: "接收总计",
      prop: "receiveTotalMoney",
      precision: 2,
      formatter: (row, value, label, column) => {
        const receiveNotes = row.receiveNotes;
        const receiveCoin = row.receiveCoin;
        let sum = 0;
        if (!isNaN(receiveNotes)) {
          sum += receiveNotes;
        }
        if (!isNaN(receiveCoin)) {
          sum += receiveCoin;
        }
        row.receiveTotalMoney = sum;
        return numberFormat(sum, column.precision);
      }
    },
    {
      type: "number",
      label: "售票总计",
      prop: "sellTicketTotalMoney",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "number",
      label: "找零总计",
      prop: "changeTotalMoney",
      precision: 2,
      formatter: (row, value, label, column) => {
        const noteChangen = row.noteChangen;
        const coinChange = row.coinChange;
        let sum = 0;
        if (!isNaN(noteChangen)) {
          sum += noteChangen;
        }
        if (!isNaN(coinChange)) {
          sum += coinChange;
        }
        row.changeTotalMoney = sum;
        return numberFormat(sum, column.precision);
      }
    },
    {
      type: "number",
      label: "充值总计",
      prop: "rechargeMoney",
      precision: 2,
      cell: true,
      step: 0
    },
    {
      type: "datetime",
      label: "开始时间",
      prop: "startTime",
      width: 205,
      format: "yyyy-MM-dd HH:mm:ss",
      valueFormat: "yyyy-MM-dd HH:mm:ss",
      cell: true
    },
    {
      type: "datetime",
      label: "结束时间",
      prop: "endTime",
      width: 205,
      format: "yyyy-MM-dd HH:mm:ss",
      valueFormat: "yyyy-MM-dd HH:mm:ss",
      cell: true
    },
    {
      type: "textarea",
      label: "备注",
      prop: "remark",
      hide: true
    },
    {
      type: "input",
      label: "创建时间",
      prop: "createTime",
      hide: true
    },
    {
      type: "input",
      label: "数据更新时间",
      prop: "updateTime",
      hide: true
    },
    {
      type: "input",
      label: "删除标志 1：删除 0：未删",
      prop: "delFlag",
      hide: true
    }
  ]
};
